package br.com.naybee.framework.client.core;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import br.com.naybee.framework.client.models.Model;
import br.com.naybee.framework.client.models.Models;
import br.com.naybee.framework.client.utils.NAYException;

public class FrontServiceController {

	@ResponseBody
	@ExceptionHandler(NAYException.class)
	@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
	public Model businessExceptions(NAYException ex) {
		Model model = Models.newModel();
		model.addError(ex.getModelError(), ex.getDetails());
		return model;
	}
}
